var direction = function(ele,callbackFn){
    var startX,
        startY,
        moveEndX,
        moveEndY,
        X,
        Y;
    var callbackFn = callbackFn || {};

   $(ele).on("touchstart", function(e) {
        e.preventDefault();
        startX = e.touches[0].pageX,
            startY = e.touches[0].pageY;
       callbackFn.startTouch && callbackFn.startTouch();
    });

   $(ele).on("touchmove", function(e) {
        e.preventDefault();
        moveEndX = e.touches[0].pageX,
            moveEndY = e.touches[0].pageY,
            X = moveEndX - startX,
            Y = moveEndY - startY;
       callbackFn.moveTouch && callbackFn.moveTouch();

        if ( Math.abs(X) > Math.abs(Y) && X > 0 ) {
            //left 2 right
            //return 1;
            callbackFn.moveRight && callbackFn.moveRight();
        }
        else if ( Math.abs(X) > Math.abs(Y) && X < 0 ) {
            //right 2 left
            //return 2;
            callbackFn.moveLeft && callbackFn.moveLeft();
        }
        else if ( Math.abs(Y) > Math.abs(X) && Y > 0) {
            //top 2 bottom
            //return 3;
            callbackFn.moveBottom && callbackFn.moveBottom();
        }
        else if ( Math.abs(Y) > Math.abs(X) && Y < 0 ) {
            //bottom 2 top
            //return 4;
            callbackFn.moveTop && callbackFn.moveTop();
        }
        else{
            //just touch
            //return 0;
            callbackFn.moveDefault && callbackFn.moveDefault();
        }
    });
};

